#include<bits/stdc++.h>
#define XH(i,a,b) for(int i=a;i<b;++i)
#define XXH(i,a,b) for(int i=a;i>b;--i)
#define ll long long
using namespace std;
int tmpINT; string tmpSTRING; char tmpCHAR; double tmpDOUBLE; ll tmpLONGLONG;

struct node
{
	int a,b;
	bool operator<(const node x)const{
		return this->b<x.b;
	}
};
int main(){
	node a[10];
	XH(i , 0 , 10)cin>>a[i].a>>a[i].b;
	sort(a,a+10);
	XH(i , 0 , 10)cout<<a[i].a<<" "<<a[i].b<<endl;
	
	return 0;
}
